import { z } from 'zod';

export const shopProductSearchSchema = z.object({
  id: z
    .string()
    .refine((v) => v === '' || !Number.isNaN(v), {
      message: '订单ID必须为数字',
    })
    .refine((v) => Number(v) >= 0 && Number.isInteger(Number(v)), {
      message: '订单ID必须为正整数',
    })
    .optional(),
  name: z.string().optional(),
  price: z
    .string()
    .refine((v) => !Number.isNaN(v), { message: '价格必须为数字' })
    .refine((v) => Number(v) >= 0, { message: '价格必须大于等于0' })
    .optional(),
  description: z.string().optional(),
  createdDateRange: z
    .object({
      from: z.date(),
      to: z.date().optional(),
    })
    .optional(),
  updatedDateRange: z
    .object({
      from: z.date(),
      to: z.date().optional(),
    })
    .optional(),
});
